package com.shuda.business.crm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.shuda.business.crm.entity.FollowUpReminderEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 跟进提醒Mapper接口
 * @author shuda
 */
@Mapper
public interface FollowUpReminderMapper extends BaseMapper<FollowUpReminderEntity> {

    /**
     * 根据用户ID和状态分页查询跟进提醒
     * @param page 分页对象
     * @param userId 用户ID
     * @param reminderStatus 提醒状态
     * @return 分页结果
     */
    IPage<FollowUpReminderEntity> selectPageByUserIdAndStatus(Page<FollowUpReminderEntity> page, 
                                                            @Param("userId") Long userId, 
                                                            @Param("reminderStatus") String reminderStatus);

    /**
     * 查询待提醒的记录
     * @param currentTime 当前时间
     * @return 待提醒的记录列表
     */
    List<FollowUpReminderEntity> selectPendingReminders(@Param("currentTime") LocalDateTime currentTime);

    /**
     * 根据客户ID查询跟进提醒
     * @param customerId 客户ID
     * @param reminderStatus 提醒状态
     * @return 跟进提醒列表
     */
    List<FollowUpReminderEntity> selectByCustomerId(@Param("customerId") Long customerId, 
                                                    @Param("reminderStatus") String reminderStatus);

    /**
     * 更新提醒状态
     * @param id 提醒ID
     * @param reminderStatus 提醒状态
     * @param actualReminderTime 实际提醒时间
     * @return 更新结果
     */
    int updateReminderStatus(@Param("id") Long id, 
                           @Param("reminderStatus") String reminderStatus, 
                           @Param("actualReminderTime") LocalDateTime actualReminderTime);
}